import request from '@/utils/request'

/**
 * 查询企业信息
 * @param query
 */
export function getEnterprise(enterpriseId) {
  return request({
    url: '/user/enterprise/getEnterprise',
    method: 'get',
    params: {
      enterpriseId: enterpriseId
    }
  })
}

/**
 * 保存企业信息
 * @param data
 */
export function saveEnterprise(data) {
  const headers = {}
  if (data.accessToken) {
    headers.accessToken = data.accessToken
  }
  return request({
    headers: headers,
    url: '/user/enterprise/saveEnterprise',
    method: 'post',
    data: data
  })
}

/**
 * 查询企业配置
 */
export function getByEnterpriseId(enterpriseId) {
  return request({
    url: '/user/enterpriseConfig/getByEnterpriseId',
    method: 'get',
    params: { enterpriseId }
  })
}
/**
 * 查询企业配置
 * @param query
 */
export function createAppSecret(enterpriseId) {
  return request({
    url: '/user/enterpriseConfig/createAppSecret',
    method: 'get',
    params: {
      enterpriseId: enterpriseId
    }
  })
}

/**
 * 保存企业配置
 * @param data
 */
export function saveEnterpriseConfig(data) {
  return request({
    url: '/user/enterpriseConfig/save',
    method: 'post',
    data: data
  })
}

/**
 * 重置签约编码
 * @param data
 */
export function resetSignCode(enterpriseId) {
  return request({
    url: '/user/enterprise/resetSignCode',
    method: 'post',
    params: { enterpriseId }
  })
}

/**
 * 注册企业信息
 * @param data
 */
export function regEnterprise(data) {
  return request({
    url: '/user/enterprise/doRegEnterprise',
    method: 'post',
    data: data
  })
}

/**
 * 注册企业信息
 * @param data
 */
export function checkEnterprisePhone(phone) {
  return request({
    url: '/user/enterprise/doCheckEnterprisePhone',
    method: 'post',
    params: { phone }
  })
}

/**
 * 获取门店版名片二维码
 */
export function getPremiumWxaCode(data) {
  return request({
    url: '/card/enterpriseStoreCardApply/getPremiumWxaCode',
    method: 'get',
    params: data
  })
}
/**
 * 获取标准版名片二维码
 */
export function getStandardWxaCode(data) {
  return request({
    url: '/card/enterpriseStoreCardApply/getStandardWxaCode',
    method: 'get',
    params: data
  })
}

/**
 * 获取企业微客
 */
export function getMemberList(enterpriseId, veekrayStatus) {
  return request({
    url: '/user/member/getMemberList',
    method: 'get',
    params: { enterpriseId, veekrayStatus }
  })
}

/**
 * 获取企业小程序首页二维码
 */
export function doHomeWxaCode(enterpriseId, appType) {
  return request({
    url: '/user/enterprise/doHomeWxaCode',
    method: 'post',
    params: { enterpriseId, appType }
  })
}

/**
 * 获取企业小程序预览二维码
 */
export function doPreviewWxaCode(enterpriseId, pageId, pageType, versionType, appType) {
  return request({
    url: '/user/enterprise/doPreviewWxaCode',
    method: 'post',
    params: { enterpriseId, pageId, pageType, versionType, appType }
  })
}

/**
 * 获取企业内部微客码
 */
export function doNatureInWxaCode(data) {
  return request({
    url: '/user/enterprise/doNatureInWxaCode',
    method: 'get',
    params: data
  })
}

/**
 * 企业分销设置
 */
export function updateDistributionType(enterprise) {
  return request({
    url: '/user/enterprise/updateDistributionType',
    method: 'post',
    params: enterprise
  })
}

/**
 * 获取主营集合
 */
export function listMainCamp() {
  return request({
    url: '/user/enterprise/listMainCamp',
    method: 'get',
    params: {}
  })
}

/**
 * 获取企业税率
 */
export function getEnterpriseTax(enterpriseId) {
  return request({
    url: '/user/enterprise/getTaxSourceAddressByEnterpriseId',
    method: 'get',
    params: { enterpriseId }
  })
}

/**
 * 企业风险验证码
 */
export function saveVerifyRiskCode(data) {
  return request({
    url: '/user/enterprise/saveVerifyRiskCode',
    method: 'get',
    params: data
  })
}

/**
 * 校验验证码
 */
export function checkRiskCode(data) {
  return request({
    url: '/user/enterprise/checkRiskCode',
    method: 'get',
    params: data
  })
}

export function savePayPassword(data) {
  return request({
    url: '/user/enterprise/savePayPassword',
    method: 'get',
    params: data
  })
}

/**
 * 首页统计
 * @param enterpriseId
 */
export function countEnterpriseDataStat(enterpriseId) {
  return request({
    url: '/user/enterprise/countEnterpriseDataStat',
    method: 'get',
    params: { enterpriseId }
  })
}

/**
 * 服务协议保存
 * @param data
 */
export function saveAgreement(data) {
  return request({
    url: '/user/enterpriseAgreement/save',
    method: 'post',
    data: data
  })
}

/**
 * 获取服务协议
 * @param enterpriseId
 * @param appType 小程序类型 10：云店小程序 11：批发小程序 13：主播小程序
 */
export function getEnterpriseAgreement(enterpriseId, type, appType) {
  return request({
    url: '/user/enterpriseAgreement/getEnterpriseAgreement',
    method: 'get',
    params: { enterpriseId: enterpriseId, type: type, appType: appType }
  })
}

export function saveOrderStatTimeInfo(params) {
  return request({
    url: '/user/enterpriseConfig/saveOrderStatTimeInfo',
    method: 'get',
    params: params
  })
}

/**
 * 查询企业配置的腾讯地图AppKey
 */
export function getEnterpriseTencentAppKeyById(enterpriseId) {
  return request({
    url: '/user/enterpriseConfig/getEnterpriseTencentAppKeyById',
    method: 'get',
    params: { enterpriseId }
  })
}
